package com.hz.ruoyiequipment.warning.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @Author: zjk
 * @Date: 2025/3/21 15:13
 * @Description: rabbitmq canal
 */

@Configuration
public class RabbitMQConfig {

    // 定义 Exchange
    @Bean
    public TopicExchange nyCanalExchange() {
        return new TopicExchange("ny-canal.exchange", true, false); // durable=true, autoDelete=false
    }

    // 定义 Queue
    @Bean
    public Queue nyCanalQueue() {
        return new Queue("ny-canal.queue", true); // durable=true
    }

    // 定义 Binding
    @Bean
    public Binding nyCanalBinding() {
        return BindingBuilder.bind(nyCanalQueue())
                .to(nyCanalExchange())
                .with("ny-canal.routing.key");
    }
}